package com.lord.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.lord.model.User;
import com.lord.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

@Controller
@Scope("prototype")
public class UserAction extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private IUserService userService;
	
	public UserAction() {
		super();
		System.out.println("Spring 创建实例");
	}


	public String show() {
		System.out.println(userService.loadUser(4L).getUserName());
		return SUCCESS;
	}
	
	public String add() {
		User user = new User();
		user.setUserName("洪楚彬");
		user.setPassword("hcb897668");
		userService.save(user);
		return SUCCESS;
	}

	@Resource
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}
	
}
